package org.koyad.portal.tags.piston;

import java.util.List;

import org.koyad.portal.annotations.TagCordinates;
import org.koyad.portal.annotations.TagType;
import org.koyad.portal.constants.FrameworkConstants;
import org.koyad.portal.context.PistonContext;
import org.koyad.portal.tags.AbstractTag;
import org.koyad.portal.utils.LogUtils;

@TagCordinates (
	uri = FrameworkConstants.PORTAL_NAMESPACE,
	localName = "errors",
	type = TagType.NOBODY 
)
public class ErrorsTag extends AbstractTag {
	
	private static final LogUtils LOGGER = LogUtils.getLogger(ErrorsTag.class);

	@Override
	public void render() {
		
		getWriter().write(_preStartTagText + "<ul>");
		
		List<String> errors = PistonContext.getContext().getViewRoot().getErrors();
		for(String error : errors) {
			getWriter().write(_preStartTagText + "\t<li>");
			getWriter().write(error);
			getWriter().write("</li>");
		}
		
		getWriter().write(_preStartTagText + "</ul>");
	}
}
